package gcj2011.round2;

import java.util.Arrays;

import common.AbstractRunner;
import common.AbstractRunner.SIZE;

public class A extends AbstractRunner {
	
	public static class Walkway implements Comparable {
		public int l, w;
		
		
		
		public Walkway(int l,  int w) {
			super();
			this.w = w;
			this.l = l;
		}



		@Override
		public int compareTo(Object o) {
			Walkway w = (Walkway)o;
			return this.w - w.w;
		}
		
		public String toString() {
			return String.format("{%d, %d}", l, w);
		}
	}
	
	public void handleCase(int caseNumber) throws Exception {
		int x = scanner.nextInt();
		int s = scanner.nextInt();
		int r = scanner.nextInt();
		double t = scanner.nextInt();
		int n = scanner.nextInt();
//		int b[] = new int[n];
//		int e[] = new int[n];
//		int w[] = new int[n];
		Walkway[] a = new Walkway[n+1];
		
		
		for (int i=0; i<n; i++) {
			int b = scanner.nextInt();
			int e = scanner.nextInt();
			int l = e - b;
			int w = scanner.nextInt();
			a[i] = new Walkway(l, w);
			x -= l;
		}
		a[n] = new Walkway(x, 0);
		
		Arrays.sort(a);
		System.out.println(String.format("%d %d %d %.0f %s", x, s, r, t, Arrays.toString(a)));
		
		double res = 0;
		for (int i=0; i<=n; i++) {			
			if (t <= 0) {
				res += a[i].l / (double)(a[i].w + s);
			} else {
				double tt = a[i].l / (double)(a[i].w + r);
				if (tt <= t) {
					res += tt;
					t -= tt;
				} else {					
					a[i].l -= t * (a[i].w + r);
					res += t;
					t = 0;
					i--;
				}
			}						
		}
		
		println(res);
	}
	
	public static void main(String[] args) throws Exception {
		new A().init(SIZE.small).execute();
	}

}
